$(function () {
    var classSchedule_datagrid = $("#classSchedule_datagrid");
    classSchedule_datagrid.datagrid({
        url: '/classSchedule/query.do',
        fit: true,
        fitColumns: true,
        columns: [[
            {field: 'id', hidden: true},
            {field: 'date', title: '日期', width: 100},
            {field: 'week', title: '星期', width: 100},
            {field: 'locationClass', title: '教室', width: 100,formatter:function (value) {
                return value?value.name:"";
            }},
            {field: 'classRoom', title: '班级', width: 100,formatter:function (value) {
                return value?value.className:"";
            }},
            {field: 'courseName', title: '课程名称', width: 100},
            {field: 'classTeacher', title: '班主任', width: 100},
            {field: 'courseTeacher', title: '上课教师', width: 100,formatter:function (value) {
                return value?value.realname:"";
            }},
            {field: 'remark', title: '备注', width: 100},
            {field: 'state', title: '状态', width: 100,formatter:function (value) {
                return value?"已上":"未上";
            }}
        ]],
        singleSelect: true,
        pagination: true,
        toolbar: "#classSchedule_btns"
        /*onClickRow: function (index, row) {
         }*/
    });
    $("a[data-cmd]").click(function () {
        var methodName = $(this).data('cmd');
        methodObject[methodName]();
    });
    var methodObject = {

        reload: function () {
            classSchedule_datagrid.datagrid('reload');
        },

        query: function () {
            var locationClassId = $("[name=locationClassId]").val();
            var classRoomId = $("[name=classRoomId]").val();
            var courseTeacherId = $("[name=courseTeacherId]").val();
            var beginDate = $("[name=beginDate]").val();
            var endDate = $("[name=endDate]").val();
            classSchedule_datagrid.datagrid('load', {
                locationClassId: locationClassId,
                classRoomId: classRoomId,
                courseTeacherId: courseTeacherId,
                beginDate: beginDate,
                endDate: endDate

            })
        }
    }
})


